<?php
/* @var $this SmsSendController */
/* @var $model SmsSend */

$this->breadcrumbs=array(
	'[临时短信通知]管理'=>array('admin'),
	'添加[临时短信通知]',
);
//设置页面标题
$this->pageTitle=Yii::app()->name.' - 添加[临时短信通知]';
$this->contentTitle='添加[临时短信通知]';
?>
<!--表单内容-->
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'sms-send-form',
	'enableAjaxValidation'=>false,
        'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>true
        ),
    'htmlOptions'=>array('class'=>'ajax_form'),
)); ?>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/editor/kindeditor-min.js"></script>
<link rel="stylesheet" href="<?php echo Yii::app()->baseUrl?>/editor/themes/default/default.css" />
<table cellspacing="1" class="myform">
	<tr>
		<td align="right"><?php echo $form->labelEx($model,'sms_id'); ?></td>
		<td>
			<?php echo $form->dropDownList($model,'sms_id',CHtml::listData(Sms::model()->findAll('is_type=1'), 'id', 'activity.title'),
                                array(
                                'prompt'=>'---请选择短信模板---',
                                'style'=>'float: left;',
                                'ajax'=>array(
                                     'type'=>'POST',
                                     'url'=>$this->createUrl('smsSend/preview'),
                                     'dataType' => 'json',
                                     'data'=>array('smsid'=>'js:this.value'),
                                     'success'=>'function(data){
                                                document.getElementById("preview").value=data.content;
                                                }',
                                ))); ?> 
			<?php echo $form->error($model,'sms_id'); ?>
		</td>
                
                
                
                
                

	</tr>
        
        <tr>
		<td align="right"><label for="SmsSend_username">短信预览</label></td>
		<td>
                    <textarea id="preview" rows="7" cols="58" readonly="readonly"></textarea></td>
                </tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($model,'username'); ?></td>
		<td>
			<?php echo $form->textField($model,'username',array('size'=>20,'maxlength'=>20,'class'=>'fl input')); ?>
			<?php echo $form->error($model,'username'); ?>
		</td>
	</tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($model,'phone'); ?></td>
		<td>
			<?php echo $form->textField($model,'phone',array('size'=>20,'maxlength'=>20,'class'=>'fl input')); ?>
			<?php echo $form->error($model,'phone'); ?>
		</td>
	</tr>

	<tr>
        <td align="right"></td>
        <td>
            <input class="but" type="submit" name="yt0" value="提 交" />        </td>
    </tr>
</table>
 <?php 
        if(Yii::app()->user->getFlash('upload_error')){
        echo "<script>art.dialog({icon:'error',content:'请选择上传文件！',time:2});</script>";
        }        
?> 
<?php $this->endWidget(); ?>
<!--表单内容-->
<div>
    <form class="ajax_form" enctype="multipart/form-data" name = "SubmitForm"
          action="<?php echo Yii::app()->baseUrl?>/index.php/smsSend/batchCreate" id="party-form" method = "post">
        <table cellspacing="1" class="myform">
            <tr>
              <td align="right">导入文件：</td> 
              <td>
                  <input class="ke-input-text" type="text" name="userfile" id="url" value="" readonly="readonly" />
                    <input type="button" id="uploadButton" value="上传文件" />
                    <input type="submit" class="but" value="批量添加">
              </td>
            </tr>
        </table>
    </form>
</div>
<script>
	KindEditor.ready(function(K) {
                var uploadbutton = K.uploadbutton({
                        button : K('#uploadButton')[0],
                        fieldName : 'imgFile',
                        url : '<?php echo Yii::app()->baseUrl?>/editor/php/upload_json.php?dir=excel',
                        afterUpload : function(data) {
                                if (data.error === 0) {
                                       var url = K.formatUrl(data.url, 'absolute');
					K('#url').val(url);
                                } else {
                                        alert(data.message);
                                }
                        },
                        afterError : function(str) {
                                alert('自定义错误信息: ' + str);
                        }
                });
                uploadbutton.fileBox.change(function(e) {
                        uploadbutton.submit();
                });
        });
</script>
